import 'package:flutter/material.dart';
import 'package:syn_4s/core/extension/int_extension.dart';
import 'package:syn_4s/ui/widgets/shadow_container.dart';

import 'main_title.dart';

class MainFold extends StatefulWidget {
  final String title;
  final Widget child;
  final Key? scrollKey;

  const MainFold({super.key, this.scrollKey,required this.title, required this.child});

  @override
  State<MainFold> createState() => _MainFoldState();
}

class _MainFoldState extends State<MainFold> {
  bool _isExpanded = true;

  @override
  Widget build(BuildContext context) {
    return ShadowContainer(
      key: widget.scrollKey,
      margin: EdgeInsets.only(top: 12.px,left: 6.px,right: 6.px),
      child: Column(
        children: [
          MainTitle(
            title: widget.title,
            onTap: () {
              setState(() {
                _isExpanded = !_isExpanded;
              });
            },
            isExpanded: _isExpanded,
          ),
          Offstage(
            offstage: !_isExpanded,
            child: widget.child,
          ),
        ],
      ),
    );
  }
}
